import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '用户',
    align:"center",
    dataIndex: 'user_dictText'
   },
   {
    title: '服务区域',
    align:"center",
    dataIndex: 'serviceArea',
   },
   {
    title: '是否启用',
    align:"center",
    dataIndex: 'status',
    customRender:({text}) => {
	   if(text==1){
	      return '启用';
	   }else{
	   return '不启用';
	   }
       //return  render.renderSwitch(text, [{text:'启用',value:'1'},{text:'不启用',value:'0'}])
     },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "用户",
      field: 'user',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "是否启用",
      field: 'status',
      /*component: 'JSwitch',
      componentProps:{
           query:true,
       },*/
	   component: 'JDictSelectTag',
	   componentProps: {
      type: 'radioButton',
      dictCode: 'dict_item_status',
      stringToNumber: true,
	  //query:true,
    },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
 {
    label: '用户',
    field: 'user',
    component: 'JSelectUserByDept',
    componentProps:{
        labelKey:'realname',
      isRadioSelection:true
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请选择用户!'},
      ];
    },
  },
  {
    label: '服务区域',
    field: 'serviceArea',
    component: 'JAreaLinkage',
	defaultValue:'520000,522600,522601',
    /*componentProps: {
      saveCode: 'region',
    },*/
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入服务区域!'},
          ];
     },
  },
  {
    field: 'status',
    label: '是否启用',
    defaultValue: 1,
    component: 'JDictSelectTag',
    componentProps: {
      type: 'radioButton',
      dictCode: 'dict_item_status',
      stringToNumber: true,
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  user: {title: '用户',order: 0,view: 'sel_user', type: 'string',},
  serviceArea: {title: '服务区域',order: 1,view: 'pca', type: 'string',},
  status: {title: '是否启用',order: 2,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}